from django.urls import re_path, path, include
from . import views
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework_simplejwt.views import token_obtain_pair
from rest_framework.routers import DefaultRouter

router = DefaultRouter()
router.register(r'addresses', views.AddressViewSet, basename='addresses')
router.register(r'roles', views.RoleViewSet)
router.register(r'user', views.UserViewSet)
urlpatterns = [
    re_path(r'^users/$', views.UserView.as_view()),
    # 判断用户名是否已注册
    re_path(r'^usernames/(?P<username>\w{5,20})/count/$', views.UsernameCountView.as_view()),
    # 判断手机号是否已注册
    re_path(r'^counts/$', views.UsersCountView.as_view()),
    re_path(r'^mobiles/(?P<mobile>1[3-9]\d{9})/count/$', views.UsernameCountView.as_view()),
    # 登录
    # re_path(r'^login/$', obtain_jwt_token),
    # jwt-simple登录
    # re_path(r'^login/$', token_obtain_pair),
    re_path(r'^refreshToken/$', views.RefreshTokensView.as_view()),
    re_path(r'^login2/$', views.Login2View.as_view()),
    # 获取用户详情
    re_path(r'^adminusers/$', views.AdminUserDetailView.as_view()),
    path('', include(router.urls)),
    # path('user/<int:pk>/', include(router.urls)),

]
